<?php

/**
 * This is the model class for table "zy_testactivity".
 *
 * The followings are the available columns in table 'zy_testactivity':
	 * @property integer $activity_id
	 * @property integer $classify_id
	 * @property string $activity_code
	 * @property string $title
	 * @property string $activity_time
	 * @property integer $provide_gift_number
	 * @property integer $Used_gift_number
	 * @property integer $user_id
	 * @property string $activity_out_time
	 * @property string $address1
	 * @property string $address2
	 * @property string $address3
	 * @property string $bak1
	 * @property string $bak2
	 * @property integer $is_delete
	 * @property string $crate_time
	 * @property string $crate_user
	 * @property string $update_time
	 * @property string $update_user
 */
class Testactivity extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Testactivity the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'zy_testactivity';
	}
	public function primaryKey()
	{
		return 'activity_id';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('classify_id, provide_gift_number, Used_gift_number, user_id, is_delete', 'numerical', 'integerOnly'=>true),
			array('title,activity_code,provide_gift_number,activity_time','required'),
			array('activity_code, activity_out_time, crate_user, update_user', 'length', 'max'=>50),
			array('title', 'length', 'max'=>300),
			array('activity_time', 'length', 'max'=>24),
			array('address1, address2, address3', 'length', 'max'=>200),
			array('bak1, bak2', 'length', 'max'=>400),
			array('crate_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('activity_id, classify_id, activity_code, title, activity_time, provide_gift_number, Used_gift_number, user_id, activity_out_time, address1, address2, address3, bak1, bak2, is_delete, crate_time, crate_user, update_time, update_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'activity_id' =>Yii::t("Testactivity","Activity ID"),
			'classify_id' =>Yii::t("Testactivity","Classify ID"),
			'activity_code' =>Yii::t("Testactivity","Activity Code"),
			'title' =>Yii::t("Testactivity","Title"),
			'activity_time' =>Yii::t("Testactivity","Activity Time"),
			'provide_gift_number' =>Yii::t("Testactivity","Provide Gift Number"),
			'Used_gift_number' =>Yii::t("Testactivity","Used Gift Number"),
			'user_id' =>Yii::t("Testactivity","User ID"),
			'activity_out_time' =>Yii::t("Testactivity","Activity Out Time"),
			'address1' =>Yii::t("Testactivity","Address1"),
			'address2' =>Yii::t("Testactivity","Address2"),
			'address3' =>Yii::t("Testactivity","Address3"),
			'bak1' =>Yii::t("Testactivity","Bak1"),
			'bak2' =>Yii::t("Testactivity","Bak2"),
			'is_delete' =>Yii::t("Testactivity","Is Delete"),
			'crate_time' =>Yii::t("Testactivity","Crate Time"),
			'crate_user' =>Yii::t("Testactivity","Crate User"),
			'update_time' =>Yii::t("Testactivity","Update Time"),
			'update_user' =>Yii::t("Testactivity","Update User"),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('activity_id',$this->activity_id);
		$criteria->compare('classify_id',$this->classify_id);
		$criteria->compare('activity_code',$this->activity_code,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('activity_time',$this->activity_time,true);
		$criteria->compare('provide_gift_number',$this->provide_gift_number);
		$criteria->compare('Used_gift_number',$this->Used_gift_number);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('activity_out_time',$this->activity_out_time,true);
		$criteria->compare('address1',$this->address1,true);
		$criteria->compare('address2',$this->address2,true);
		$criteria->compare('address3',$this->address3,true);
		$criteria->compare('bak1',$this->bak1,true);
		$criteria->compare('bak2',$this->bak2,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('crate_time',$this->crate_time,true);
		$criteria->compare('crate_user',$this->crate_user,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('update_user',$this->update_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
			'sort'=>array(  
           		 'defaultOrder'=>'activity_id DESC',  
       		 ),  
       		'pagination'=>array(  
           		 'pageSize'=>5 
       		 ),  
		));
	}
}